home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5392 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: gidora.kralizec.net.au!root
  2. From: rosko@zeta.org.au (Ross McKay)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: for loop question
  5. Date: Sun, 04 Feb 1996 09:53:10 GMT
  6. Organization: Soft Technologies
  7. Message-ID: <4f1si7$2l1@gidora.kralizec.net.au>
  8. References: <4emqf8$470@opal.southwind.net> <4eor22$r83@dub-news-svc-5.compuserve.com> <00001a81+000098cc@msn.com>
  9. Reply-To: rosko@zeta.org.au
  10. NNTP-Posting-Host: dialup48.syd1.zeta.org.au
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. mgerrans@msn.com (Matt Gerrans) wrote:
  14.  
  15. >...Actually, it's more like "do the loop *then* do the third" part of 
  16. >the for, since the third (usually increment) part is done after the 
  17. >body of the loop.
  18.  
  19. No, actually its:
  20.  
  21. a)  do the initialising bit;
  22. b)  while (condition) do
  23. c)      statement;
  24. d)  "increment" (or otherwise)
  25.  
  26. The "middle" bit (test condition) is executed before the statement, so
  27. if I write:
  28.  
  29. for (int i = 0; i > 0; i++)
  30.     cout << "this will never print" << endl;
  31.  
  32. there will be no output.
  33.  
  34. ------------------------------------------------------------------
  35. Ross McKay        | snail: GPO Box 562, Sydney NSW 2001 Australia
  36. Soft Technologies | email: mailto:rosko@zeta.org.au
  37. Sydney, Australia |   URL: http://www.zeta.org.au/~rosko
  38. ------------------------------------------------------------------
  39. The opinions expressed are my own, not those of Soft Technologies.
  40.     "The beatings will continue, until staff morale improves."
  41.  
  42.